﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="OrderDetails.aspx.cs" Inherits="Otgruzka.WebForms.OrderDetails" %>
<%@ Register Src="~/Controls/Order/OrderDetails.ascx" TagName="OrderDetails" TagPrefix="uc" %>
<%@ Register Src="~/Controls/ExpendBill/ExpendBillList.ascx" TagName="ExpendBillList" TagPrefix="uc" %>

<asp:Content ID="headContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="mainContent" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
function sendmle() {
    $(function () {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        $("#sendmle-modal").dialog({
            width: 900,
            height: $(window).height()-40,
            modal: true,
            create: function (event, ui) {
                $("body").css({ overflow: 'hidden' })
            },
            beforeClose: function (event, ui) {
                $("body").css({ overflow: 'inherit' })
            }
        });
    });
    var sendmle = document.getElementById("sendmle-modal");
    //sendmle.innerHTML = "<iframe src=\"/WebForms/SendBoss.aspx?oid=<%= Request.QueryString["oid"] %>\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>";
    //sendmle.innerHTML = '<%=string.Format("<iframe src=\"{0}?oid={1}\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>", ResolveUrl("~/WebForms/SendBoss.aspx"), Request.QueryString["oid"]) %>';

    //var detailsControl = document.getElementById("<%=OrderDetailsControl.ClientID %>");
    //var txtContactName = document.getElementById("MainContent_ctl00_ContactName");
//    var txtContactName = document.getElementById("<%=OrderDetailsControl.ContactNameClientID %>");
//    var cname = "";
//    if (txtContactName) {
//        var nme = txtContactName.value;
//        if (nme) {
//            cname = nme;
//        }
//    }


    //    sendmle.innerHTML = '<%=string.Format("<iframe src=\"{0}?oid={1}&cname=' + cname  + '\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>", ResolveUrl("~/WebForms/SendBoss.aspx"), Request.QueryString["oid"]) %>';
    sendmle.innerHTML = '<%=string.Format("<iframe src=\"{0}?oid={1}\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>", ResolveUrl("~/WebForms/SendBoss.aspx"), Request.QueryString["oid"]) %>';
}

function closeDialog2Window(sendedOK) {
    $("#sendmle-modal").dialog("close");
    if (sendedOK == "True") {
        var btnSendBoss = document.getElementById("<%=btnSendBoss.ClientID %>");
        if (btnSendBoss) {
            btnSendBoss.click();
        }
    }
//    else {
//        window.location.href = window.location.href;
//    }
}


function delayDeliveryInfo() {
    $(function () {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        $("#delayDeliveryInfo-modal").dialog({
            width: 550,
            height: 200,
            modal: true,
            create: function (event, ui) {
                $("body").css({ overflow: 'hidden' })
            },
            beforeClose: function (event, ui) {
                $("body").css({ overflow: 'inherit' })
            }
        });
    });
    var delayDeliveryInfo = document.getElementById("delayDeliveryInfo-modal");
    delayDeliveryInfo.innerHTML = '<%=string.Format("<iframe src=\"{0}\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>", ResolveUrl("~/WebForms/DelayDeliveryInfo.aspx")) %>';
}
function closeDialogDelayDeliveryInfo2Window() {
    $("#delayDeliveryInfo-modal").dialog("close");
}


function sendauthor() {
    $(function () {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $("#dialog:ui-dialog").dialog("destroy");

        $("#sendauthor-modal").dialog({
            width: 900,
            height: $(window).height() - 40,
            modal: true,
            create: function (event, ui) {
                $("body").css({ overflow: 'hidden' })
            },
            beforeClose: function (event, ui) {
                $("body").css({ overflow: 'inherit' })
            }
        });
    });
    var sendauthor = document.getElementById("sendauthor-modal");
    sendauthor.innerHTML = '<%=string.Format("<iframe src=\"{0}?oid={1}\" width=\"100%\" height=\"99%\" frameborder=\"0\" scrolling=\"yes\"></iframe>", ResolveUrl("~/WebForms/SendToAuthor.aspx"), Request.QueryString["oid"]) %>';
}

function closeDialogSendAuthorWindow(sendedOK) {
    $("#sendauthor-modal").dialog("close");
    if ((sendedOK == "true") || sendedOK == "") {
        window.location.href = window.location.href;
    }
    else {
        var errorMessage = document.getElementById("<%=ErrorMessage.ClientID %>");
        if (errorMessage) {
            errorMessage.val(sendedOK);
        }
    }
}

$(function() {
		$( "#tabs" ).tabs();
        $("#tabs-1").append($("#OrderInfo"));
        $("#tabs-2").append($("#ExpendedBills"));
	});

    </script>
    <div id="sendmle-modal" style="margin: 5px;" title="Отправить руководителю">
    </div>

    <div id="sendauthor-modal" style="margin: 5px;" title="Отправить уведомление автору">
    </div>

    <div id="delayDeliveryInfo-modal" style="margin: 5px;" title="Сроки доставки заказа">
    </div>

    <div id="error_string" style="font-weight:bold;color:Red;">
        <asp:Label ID="ErrorMessage" runat="server" />
    </div>

    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">Заказ</a></li>
            <li><a href="#tabs-2">Расходные накладные</a></li>
        </ul>
        <div id="tabs-1">
            <table id="OrderInfo">
                <tr>
                    <td style="width: 80%;">
                        <uc:OrderDetails ID="OrderDetailsControl" runat="server" />
                        <br />
                        <div>
                            <span style="margin-right: 10px;">
                                <asp:Button runat="server" Text="Удалить Заказ" ID="btnDeleteOrder" OnClick="btnDeleteOrder_Click" />
                            </span>
                            <asp:Button runat="server" Text="Внести изменения" ID="btnBackToStatusProject" OnClick="btnBackToStatusProject_Click" />
                            <asp:Button runat="server" Text="Отредактировать" ID="btnModifiedAdmin" OnClick="btnModifiedAdmin_Click" />
                            <asp:Button runat="server" Text="Отправить руководителю" ID="btnOpenWindowSendBoss" OnClientClick="javascript: sendmle(); return false;" />
                            <div class="hidden">
                                <asp:Button runat="server" Text="Отправить руководителю" ID="btnSendBoss" OnClick="btnSendBoss_Click" />
                            </div>
                            <div class="hidden">
                            <asp:Button runat="server" Text="Отправить уведомление автору" ID="btnSendAuthor" OnClientClick="javascript: sendauthor(); return false;" />
                            </div>
                            <asp:Button runat="server" Text="Сформировать Счет" ID="btnNewAccount" OnClick="btnNewAccount_Click" />
                            <asp:Button runat="server" Text="Расходная накладная" ID="btnExpendBill" OnClick="btnExpendBill_Click" Visible="false" />
                            <script>
                                function openprintwin() { 
                                    //var oid = <%= Request.QueryString["oid"] %>;
                                    //window.open('/WebForms/OrderDetailsPrint.aspx?oid='+oid,'print');
                                    window.open('<%=string.Format("{0}?oid={1}", ResolveUrl("~/WebForms/OrderDetailsPrint.aspx"), Request.QueryString["oid"]) %>', 'print');
                                }
                            </script>
                            <asp:Button runat="server" Text="Печать" ID="btnPrintBill" OnClientClick="javascript: openprintwin(); return false; " />

                            <asp:Button runat="server" Text="Excel" ID="btnExcelButton" OnClick="btnExcelButton_Click" Visible="true" />

                        </div>
                    </td>
                    <td style="width: 20%;">
                        <asp:Repeater ID="PromptMessagesRepeater" runat="server" Visible="false">
                            <ItemTemplate>
                                <div class="helpdiv" style="margin: 2px;">
                                    <%--style="width:49%;float:right;"--%>
                                    <asp:Label ID="id" runat="server">
                                <%--<%# DataBinder.Eval(Container.DataItem, "Message")%>--%>
                                <%# Container.DataItem %>
                                    </asp:Label>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                    </td>
                </tr>
            </table>
        </div>
        <div id="tabs-2">
            <table id="ExpendedBills">
                <tr>
                    <td style="width: 80%;">
                        <uc:ExpendBillList runat="server" ID="ebList" />
                    </td>
                    <td style="width: 20%;">


                    </td>
                </tr>
            </table>
        </div>
    </div>
</asp:Content>
